from selenium.webdriver.common.by import By
import time
from  WebTest.WebAutomationEncapsulation.PageElementEncapsulation.page_data_login import UserLoginPage
#
from WebTest.WebAutomationEncapsulation.buy.My_password import MyPassword


class PageBuyLingQianFinance:

    def __init__(self, driver):
        self.driver = driver

    # 购买个人理财下的零钱理财中的支付宝零钱理财
    def buy_alipay_finance(self,username,password):
        UserLoginPage.login_page(self,username,password)
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a').click()
        self.driver.find_element(By.XPATH,
                                 '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button').click()
        time.sleep(1)
        MyPassword.pas_in(self.driver)

    def buy_alipay_finance_success_message(self):
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/ul/li[1]/a').click()
        return self.driver.find_element(By.XPATH,
                                        '/html/body/div/div/main/div/div/div/div/div[2]/div[1]/div[2]/div/table/tbody/tr[last()]/td[2]').text

    # 购买个人理财下的零钱理财中的微信零钱理财
    def buy_weixin_finance(self):
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a').click()
        self.driver.find_element(By.XPATH,
                                 '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[2]/td[6]/button').click()
        time.sleep(1)
        MyPassword.pas_in(self.driver)

    def buy_weixin_finance_success_message(self):
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/ul/li[1]/a').click()
        return self.driver.find_element(By.XPATH,
                                        '/html/body/div/div/main/div/div/div/div/div[2]/div[1]/div[2]/div/table/tbody/tr[last()]/td[2]').text

    # 购买个人理财下的零钱理财中的理财通零钱理财
    def buy_lingqiantong_finance(self):
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a').click()
        self.driver.find_element(By.XPATH,
                                 '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[3]/td[6]/button').click()
        time.sleep(1)
        MyPassword.pas_in(self.driver)

    def buy_lingqiantong_finance_success_message(self):
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/ul/li[1]/a').click()
        return self.driver.find_element(By.XPATH,
                                        '/html/body/div/div/main/div/div/div/div/div[2]/div[1]/div[2]/div/table/tbody/tr[last()]/td[2]').text

    # 购买个人理财下的零钱理财中的云闪付零钱理财
    def buy_yunsanfu_finance(self):
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a').click()
        self.driver.find_element(By.XPATH,
                                 '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[4]/td[6]/button').click()
        time.sleep(1)
        MyPassword.pas_in(self.driver)

    def buy_yunsanfu_finance_success_message(self):
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/ul/li[1]/a').click()
        return self.driver.find_element(By.XPATH,
                                        '/html/body/div/div/main/div/div/div/div/div[2]/div[1]/div[2]/div/table/tbody/tr[last()]/td[2]').text

    # 购买个人理财下的零钱理财中的度小满零钱理财
    def buy_duxiaoman_finance(self):
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a').click()
        self.driver.find_element(By.XPATH,
                                 '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[5]/td[6]/button').click()
        time.sleep(1)
        MyPassword.pas_in(self.driver)

    def buy_duxiaoman_finance_success_message(self):
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/a').click()
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/aside/div[2]/nav/ul/li[4]/ul/li[1]/a').click()
        return self.driver.find_element(By.XPATH,
                                        '/html/body/div/div/main/div/div/div/div/div[2]/div[1]/div[2]/div/table/tbody/tr[last()]/td[2]').text
